package com.brzjomo.secretiveworld.init;

import java.util.Locale;

import com.brzjomo.secretiveworld.SecretiveWorld;
import com.brzjomo.secretiveworld.world.gen.feature.structure.abandoned.house.AbandonedHouseConfig;
import com.brzjomo.secretiveworld.world.gen.feature.structure.abandoned.house.AbandonedHousePiece;
import com.brzjomo.secretiveworld.world.gen.feature.structure.abandoned.house.AbandonedHouseStructure;
import com.brzjomo.secretiveworld.world.gen.feature.structure.corpse.CorpseOfAnUnknownTravelerConfig;
import com.brzjomo.secretiveworld.world.gen.feature.structure.corpse.CorpseOfAnUnknownTravelerPiece;
import com.brzjomo.secretiveworld.world.gen.feature.structure.corpse.CorpseOfAnUnknownTravelerStructure;
import com.brzjomo.secretiveworld.world.gen.feature.structure.test.TestStructure;
import com.brzjomo.secretiveworld.world.gen.feature.structure.test.TestStructureConfig;
import com.brzjomo.secretiveworld.world.gen.feature.structure.test.TestStructurePiece;

import net.minecraft.util.registry.Registry;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.structure.IStructurePieceType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

@Mod.EventBusSubscriber(bus = Bus.MOD, modid = SecretiveWorld.MODID)
public class ModFeatures {

	@SuppressWarnings("deprecation")
	public static final DeferredRegister<Feature<?>> FEATURES = new DeferredRegister<Feature<?>>(
			ForgeRegistries.FEATURES, SecretiveWorld.MODID);

	public static IStructurePieceType TEST_STRUCTURE_PIECE = TestStructurePiece.Piece::new;
	public static IStructurePieceType ABANDONED_HOUSE_PIECE = AbandonedHousePiece.Piece::new;
	public static IStructurePieceType CORPSE_OF_AN_UNKNOWN_TRAVELER_PIECE = CorpseOfAnUnknownTravelerPiece.Piece::new;

	public static final RegistryObject<TestStructure> TEST_STRUCTURE = FEATURES.register("test_structure",
			() -> new TestStructure(TestStructureConfig::deserialize));
	public static final RegistryObject<AbandonedHouseStructure> ABANDONED_HOUSE = FEATURES.register("abandoned_house",
			() -> new AbandonedHouseStructure(AbandonedHouseConfig::deserialize));
	public static final RegistryObject<CorpseOfAnUnknownTravelerStructure> CORPSE_OF_AN_UNKNOWN_TRAVELER = FEATURES.register("corpse_of_an_unknown_traveler",
			() -> new CorpseOfAnUnknownTravelerStructure(CorpseOfAnUnknownTravelerConfig::deserialize));

	@SubscribeEvent
	public static void registerStructurePieces(RegistryEvent.Register<Feature<?>> event) {
		Registry.register(Registry.STRUCTURE_PIECE, "Test_Structure".toLowerCase(Locale.ROOT), TEST_STRUCTURE_PIECE);
		Registry.register(Registry.STRUCTURE_PIECE, "Abandoned_House".toLowerCase(Locale.ROOT), ABANDONED_HOUSE_PIECE);
		Registry.register(Registry.STRUCTURE_PIECE, "Corpse_Of_An_Unknown_Traveler".toLowerCase(Locale.ROOT), CORPSE_OF_AN_UNKNOWN_TRAVELER_PIECE);
	}
}
